﻿#include "stream.h"
#include "stdint.h"
uint8_t *file_buff;


// 读取h264文件，读取失败返回-1，否则返回文件大小
int readAnnexbBitStreamFile(const char *fp, long long MAX_BUFFER_SIZE)
{
	FILE *fp_h264 = NULL;
	//fopen_s(&fp_h264, fp, "rb");

 //   if (fp_h264 == NULL) {
 //       printf("打开h264文件失败\n");
 //       return -1;
 //   }

	fp_h264 = fopen(fp, "rb+");
	if (fp_h264 == NULL) {
		printf("Open file error\n");
		return 0;
	}

	file_buff = (uint8_t *)malloc(MAX_BUFFER_SIZE * sizeof(uint8_t));
	int file_size = (int)fread(file_buff, sizeof(uint8_t), MAX_BUFFER_SIZE, fp_h264);
	fclose(fp_h264);



	return file_size;
}

void freeFilebuffer(void)
{
	free(file_buff);
}


